package com.example.gomoku;

import static com.example.gomoku.DBHelper.uriMatcher;

import android.content.ContentProvider;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public class UserContentProvider extends ContentProvider {
    private com.example.gomoku.DBHelper dbHelper;

    public  static final String AUTHORTY="com.example.beautycamera";
    private  static final  int TABLE_USER = 0;
    private  static final int TABLE_ADDRESS = 1;

    static {
       // uriMatcher.addURI( AUTHORTY,DBHelper.TABLE_USER,null );
    }

    @Override
    public boolean onCreate(){
        Log.i("xxxTAG","onCreate:UserContentProvider");
        dbHelper = new com.example.gomoku.DBHelper( getContext() );
        return true;

    }

    @Nullable
    @Override
    public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection, @Nullable String[] selectionArgs, @Nullable String sortOrder) {
        int code=uriMatcher.match( uri );
        SQLiteDatabase db =dbHelper.getReadableDatabase();
        switch (code){
            case TABLE_USER:
                return db.query( com.example.gomoku.DBHelper.TABLE_USER,projection,selection,selectionArgs,null,null,sortOrder );
            case TABLE_ADDRESS:
                return db.query( com.example.gomoku.DBHelper.TABLE_USER,projection,selection,selectionArgs,null,null,sortOrder );

        }
        return null;
    }

    @Nullable
    @Override
    public String getType(@NonNull Uri uri) {
        return null;
    }

    @Nullable
    @Override
    public Uri insert(@NonNull Uri uri, @Nullable ContentValues values) {
        int code = uriMatcher.match(uri);
        String tablename;
        switch (code){
            case TABLE_USER:
                //tablename = TABLE_USER;

        }



    //插入哪个表格

        return uri;
    }

    @Override
    public int delete(@NonNull Uri uri, @Nullable String selection, @Nullable String[] selectionArgs) {
        return 0;
    }

    @Override
    public int update(@NonNull Uri uri, @Nullable ContentValues values, @Nullable String selection, @Nullable String[] selectionArgs) {
        return 0;
    }
}
